<template>
  <div class="item-size-choose" @touchmove.stop.prevent>
    <div
      :class="{
        mask: true,
        animated: true,
        fadeIn: !pageLeave,
        fadeOut: pageLeave
      }"
      @click="maskClick"
    ></div>
    <div
      :class="{
        'choose-panel': true,
        animated: true,
        slideInUp: !pageLeave,
        slideOutDown: pageLeave
      }"
      @click.stop
    >
      <div class="sex-list">
        <div
          class="sex-cell with-grey-bottom-border"
          @click="sexChoose(item.id)"
          v-for="item in sexList"
        >
          {{ item.name }}
        </div>
      </div>
      <div class="bottom-btn">
        <button @click="maskClick()">取消</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      sexList: [{ name: "男", id: 1 }, { name: "女", id: 2 }],
      pageLeave: false
    };
  },
  methods: {
    maskClick() {
      this.pageLeave = true;
      setTimeout(() => {
        this.$emit("panelClose", "");
      }, 400);
    },
    sexChoose(id) {
      this.$emit("sexChoose", id);
      this.maskClick();
    }
  },
  components: {},
  mounted() {}
};
</script>

<style lang="less" scoped>
.item-size-choose {
  z-index: 9999;
  position: relative;

  .mask {
    animation-duration: 0.4s;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6);
  }

  .choose-panel {
    animation-duration: 0.4s;
    z-index: 10000;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    background: rgba(255, 255, 255, 1);

    .sex-list {
      .sex-cell {
        height: 2rem;
        line-height: 2rem;
        font-size: 0.64rem;
        color: #444444;
        text-align: center;
      }
    }

    .bottom-btn {
      height: 2rem;
      background: #fff;
      padding: 0.3rem 3.2%;

      button {
        width: 100%;
        font-weight: bold;
        color: #0078ff;
        font-size: 0.64rem;
        background: rgba(255, 255, 255, 1);
        border: none;
        border-radius: 0.7rem;
        height: 1.4rem;
      }
    }
  }
}
</style>
